/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.model.crs.transf;

import static java.lang.Math.*;
import chunmap.model.coord.Coordinate2D;
import chunmap.model.coord.Position;

public class PlanTransform  extends SphericalPolar{

	public PlanTransform(double f0, double l0) {
		super(f0, l0);
	}

	@Override
	public Position convert(Position p) {
		double f=toRadians( p.getY());
		double l=toRadians( p.getX());
		
		double cosz=cosz(f,l);
		double cota=sinzcosa(f,l)/sinzsina(f,l);
		double x=atan(cota/cosz);
		double cosx=cos(x);
		double y=atan(cosx/cosz);
		
		return new Coordinate2D(y,x);
	}

}